package com.github.sort;

public class InsertSort {
    private InsertSort(){}
    public static void insertSort(Comparable[] R){
        for (int i = 1; i < R.length; i++) {
            for (int j = i; j >0&&less(R[j],R[i] ); j--) {
                Comparable temp=R[j-1];
                R[j-1]=R[j];
                R[j]=temp;
            }
        }
    }
    private static boolean less(Comparable v,Comparable w){
        return v.compareTo(w)<0;
    }
}
